package com.bw.controller;

import com.bw.domain.TbMenu;
import com.bw.domain.User;
import com.bw.service.MainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;


/**
 * @Author: Wrj
 * @Date: 2025/3/8 11:28
 * @Description:
 **/
@Controller
public class MainController {

    @Autowired
    MainService mainService;

    @Autowired
    RedisTemplate redisTemplate;


    @RequestMapping("main")
    public String main(HttpSession session,Model model){
        User user = (User) session.getAttribute("user");

        List<TbMenu> tbMenuList = (List<TbMenu>) redisTemplate.opsForValue().get("menu" + user.getUserId());
        System.out.println(tbMenuList);
        model.addAttribute("list",tbMenuList);

        return "main";
    }
}
